package com.sqoop.core.msg;

import java.io.Serializable;
import java.util.UUID;

/**
 * Created by zw on 2017/11/6.
 */
public  abstract class Msg implements Serializable,Comparable<Msg>{
    //创建时间
    private long captruetime = System.currentTimeMillis();

    //优先级
    private int priority = 5;
    //唯一ID
    private String msgid = UUID.randomUUID().toString();

    private String srcTaskName;

    private String dstTaskName;

    public long getCaptruetime() {
        return captruetime;
    }

    public void setCaptruetime(long captruetime) {
        this.captruetime = captruetime;
    }

    public int getPriority() {
        return priority;
    }

    public void setPriority(int priority) {
        this.priority = priority;
    }

    public String getMsgid() {
        return msgid;
    }

    public void setMsgid(String msgid) {
        this.msgid = msgid;
    }

    public String getSrcTaskName() {
        return srcTaskName;
    }

    public void setSrcTaskName(String srcTaskName) {
        this.srcTaskName = srcTaskName;
    }

    public String getDstTaskName() {
        return dstTaskName;
    }

    public void setDstTaskName(String dstTaskName) {
        this.dstTaskName = dstTaskName;
    }

    @Override
    public int compareTo(Msg msg) {
        if (priority < msg.priority){
            return  -1;
        }else if (priority > msg.priority){
            return 1;
        }else {
            if (captruetime < msg.captruetime) {
                return 1;
            } else {
                return -1;
            }
        }
    }
}